package lyo.levelup.swing.hometask1;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Toolkit;
import javax.swing.JPanel;
import lyo.levelup.swing.eventsclasswork.MainPanel;

public class MoveFrame
{
    private double xCoord;
    private double yCoord;
    private int R = 100;
    private Double xNewCoord;
    private Double yNewCoord;
    private MainWindow newWindow;
    private TextPanel tp;
    private ButtonComponents compBut;

    public MoveFrame()
    {
        newWindow = new MainWindow();
        Toolkit myToolkit = Toolkit.getDefaultToolkit();
        Dimension screenSize = myToolkit.getScreenSize();
        newWindow.setxNew(screenSize.width / 2);
        newWindow.setyNew(screenSize.height / 2);
        xCoord = newWindow.getXcoord();
        yCoord = newWindow.getYcoord();
    }
    
    public Double getxNewCoord()
    {
        return xNewCoord;
    }

    public Double getyNewCoord()
    {
        return yNewCoord;
    }

    public void circleMoveFrame()
    {
        
        try
        {
            for (Integer i = 0; i <= 360; i++)
            {
                xNewCoord = xCoord + R * Math.cos(i.doubleValue() * Math.PI / 180);
                yNewCoord = yCoord + R * Math.sin(i.doubleValue() * Math.PI / 180);
                newWindow.setxNew(xNewCoord);
                newWindow.setyNew(yNewCoord);
                newWindow.drawFrame();
                Thread.sleep(50);
                if (i == 360)
                {
                    i = 0;
                }
            }
        }
        catch (Exception e)
        {
            e.printStackTrace();
        }
    }
}